package com.bw.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/***************************
 FileAction:

 CreateTime:2022-08-17 15:34
 Author:Aaking-aline
 ****************************/
@WebServlet("/login")
public class LoginServlet extends HttpServlet {
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String username = request.getParameter("username"); // 接收前端发送过来的数据
		String password = request.getParameter("password");

		response.setCharacterEncoding("GBK");
		if(username.equals("zhou") && password.equals("1234")){   // 判断账号密码是否匹配
			response.getWriter().write("{ret:200,data:message:\"登录成功\"}");
		}else{
			response.getWriter().write("{ret:400,data:message:\"登录失败\"}");
		}

	}
}
